DBI-798: Safer check on mirror validation with MySQL sources setting server_id#4564
DBI-798: Safer check on mirror validation with MySQL sources setting server_id#4564pfcoperez wants to merge 2 commits into
Conversation
…server_id It adds a check on the utilization in the source DB of the server_id.
Code reviewFound 1 issue. Checked for bugs and CLAUDE.md compliance. Bug: nil pointer dereference at flow/cmd/validate_mirror.go:199 mysqlConn.Conn() returns nil at this call site, causing a panic inside HasReplicaWithServerId. MySqlConnector uses lazy connection initialization. NewMySqlConnector stores conn as nil and never calls connect(). The actual TCP connection is only established on-demand via Execute()/withRetries(), which internally call connect(). Conn() is just c.conn.Load() — a bare atomic load that returns nil until a connection has been established. Since connectors.GetAs only calls the constructor (no queries), Conn() returns nil. HasReplicaWithServerId then calls conn.Execute(SHOW REPLICAS) on nil, which panics. Suggested fix: Change HasReplicaWithServerId to accept the MySqlConnector (or a context + an interface with Execute) so it goes through the lazy-connect path, or trigger connection establishment before calling Conn(). |
|
|
||
| // beyond other PeerDB mirrors (checked below), the pinned server_id must not be already registered | ||
| // as a replica on the source DB itself. | ||
| mysqlConn, mysqlClose, err := connectors.GetAs[*connmysql.MySqlConnector](ctx, cfg.Env, peer) |
There was a problem hiding this comment.
nit: can avoid an extra connect/disconnect by moving mysql_validation.HasReplicaWithServerId inside ValidateMirrorSource and pass in an already instantiated conn, although i understand that having this here put server_id validation check together. Your call.
❌ 4 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
❌ Test FailureAnalysis: The PR's own new test TestValidateCDCMirror_ServerIDPeerReuse fails deterministically across all three MySQL matrix jobs with an "internal server error" RPC response, indicating a real bug in the new server_id validation code rather than a flaky/timing/network issue. |
|
(pending integrations test fixes) |
It adds a check on the utilization of the same
server_idin the source MySQL server.This offer an extra layer of protection against collisions with other replication actors.